<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>qLibc: containers/qlist.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('qlist_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">qlist.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Doubly Linked-list implementation.  
<a href="#details">More...</a></p>

<p><a href="qlist_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a171f1b505417b5a936e198993c9cb372"><td class="memItemLeft" align="right" valign="top">qlist_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a> (int options)</td></tr>
<tr class="memdesc:a171f1b505417b5a936e198993c9cb372"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create new qlist_t linked-list container.  <a href="#a171f1b505417b5a936e198993c9cb372">More...</a><br/></td></tr>
<tr class="separator:a171f1b505417b5a936e198993c9cb372"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad269a073f8f138a89d91fffccf4878b2"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#ad269a073f8f138a89d91fffccf4878b2">qlist_setsize</a> (qlist_t *list, size_t max)</td></tr>
<tr class="memdesc:ad269a073f8f138a89d91fffccf4878b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;setsize(): Limit maximum number of elements allowed in this list.  <a href="#ad269a073f8f138a89d91fffccf4878b2">More...</a><br/></td></tr>
<tr class="separator:ad269a073f8f138a89d91fffccf4878b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a362b854c881d11e4ff063bf2415e1202"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a362b854c881d11e4ff063bf2415e1202">qlist_addfirst</a> (qlist_t *list, const void *data, size_t size)</td></tr>
<tr class="memdesc:a362b854c881d11e4ff063bf2415e1202"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;addfirst(): Inserts a element at the beginning of this list.  <a href="#a362b854c881d11e4ff063bf2415e1202">More...</a><br/></td></tr>
<tr class="separator:a362b854c881d11e4ff063bf2415e1202"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5fd1656d6b3534341d7775b201b70f3d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a5fd1656d6b3534341d7775b201b70f3d">qlist_addlast</a> (qlist_t *list, const void *data, size_t size)</td></tr>
<tr class="memdesc:a5fd1656d6b3534341d7775b201b70f3d"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;addlast(): Appends a element to the end of this list.  <a href="#a5fd1656d6b3534341d7775b201b70f3d">More...</a><br/></td></tr>
<tr class="separator:a5fd1656d6b3534341d7775b201b70f3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a29a98c9eb9a93b096ca15db02010059a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a29a98c9eb9a93b096ca15db02010059a">qlist_addat</a> (qlist_t *list, int index, const void *data, size_t size)</td></tr>
<tr class="memdesc:a29a98c9eb9a93b096ca15db02010059a"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;addat(): Inserts a element at the specified position in this list.  <a href="#a29a98c9eb9a93b096ca15db02010059a">More...</a><br/></td></tr>
<tr class="separator:a29a98c9eb9a93b096ca15db02010059a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae591e0ee1380e484a7707beed87ada6f"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#ae591e0ee1380e484a7707beed87ada6f">qlist_getfirst</a> (qlist_t *list, size_t *size, bool newmem)</td></tr>
<tr class="memdesc:ae591e0ee1380e484a7707beed87ada6f"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;getfirst(): Returns the first element in this list.  <a href="#ae591e0ee1380e484a7707beed87ada6f">More...</a><br/></td></tr>
<tr class="separator:ae591e0ee1380e484a7707beed87ada6f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8aa5812e608102e152a4e6c906fd848c"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a8aa5812e608102e152a4e6c906fd848c">qlist_getlast</a> (qlist_t *list, size_t *size, bool newmem)</td></tr>
<tr class="memdesc:a8aa5812e608102e152a4e6c906fd848c"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;getlast(): Returns the last element in this list.  <a href="#a8aa5812e608102e152a4e6c906fd848c">More...</a><br/></td></tr>
<tr class="separator:a8aa5812e608102e152a4e6c906fd848c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5158e057b797633b43190806fc49ce8"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#ae5158e057b797633b43190806fc49ce8">qlist_getat</a> (qlist_t *list, int index, size_t *size, bool newmem)</td></tr>
<tr class="memdesc:ae5158e057b797633b43190806fc49ce8"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;getat(): Returns the element at the specified position in this list.  <a href="#ae5158e057b797633b43190806fc49ce8">More...</a><br/></td></tr>
<tr class="separator:ae5158e057b797633b43190806fc49ce8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab988e96c223ecdf63105f6797e42ecd9"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#ab988e96c223ecdf63105f6797e42ecd9">qlist_popfirst</a> (qlist_t *list, size_t *size)</td></tr>
<tr class="memdesc:ab988e96c223ecdf63105f6797e42ecd9"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;popfirst(): Returns and remove the first element in this list.  <a href="#ab988e96c223ecdf63105f6797e42ecd9">More...</a><br/></td></tr>
<tr class="separator:ab988e96c223ecdf63105f6797e42ecd9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a19d80e0634bda2350372bc15f5b92970"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a19d80e0634bda2350372bc15f5b92970">qlist_poplast</a> (qlist_t *list, size_t *size)</td></tr>
<tr class="memdesc:a19d80e0634bda2350372bc15f5b92970"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;getlast(): Returns and remove the last element in this list.  <a href="#a19d80e0634bda2350372bc15f5b92970">More...</a><br/></td></tr>
<tr class="separator:a19d80e0634bda2350372bc15f5b92970"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a083e4eb3b82834756608e88a15a38164"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a083e4eb3b82834756608e88a15a38164">qlist_popat</a> (qlist_t *list, int index, size_t *size)</td></tr>
<tr class="memdesc:a083e4eb3b82834756608e88a15a38164"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;popat(): Returns and remove the element at the specified position in this list.  <a href="#a083e4eb3b82834756608e88a15a38164">More...</a><br/></td></tr>
<tr class="separator:a083e4eb3b82834756608e88a15a38164"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bbafb0265dbbd962629fbc6beec9a9d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a7bbafb0265dbbd962629fbc6beec9a9d">qlist_removefirst</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a7bbafb0265dbbd962629fbc6beec9a9d"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;removefirst(): Removes the first element in this list.  <a href="#a7bbafb0265dbbd962629fbc6beec9a9d">More...</a><br/></td></tr>
<tr class="separator:a7bbafb0265dbbd962629fbc6beec9a9d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2148cf9191e31eed686f9c3894ee7fc9"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a2148cf9191e31eed686f9c3894ee7fc9">qlist_removelast</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a2148cf9191e31eed686f9c3894ee7fc9"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;removelast(): Removes the last element in this list.  <a href="#a2148cf9191e31eed686f9c3894ee7fc9">More...</a><br/></td></tr>
<tr class="separator:a2148cf9191e31eed686f9c3894ee7fc9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8fafa8e268392b76496f752d9e010c6"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#af8fafa8e268392b76496f752d9e010c6">qlist_removeat</a> (qlist_t *list, int index)</td></tr>
<tr class="memdesc:af8fafa8e268392b76496f752d9e010c6"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;removeat(): Removes the element at the specified position in this list.  <a href="#af8fafa8e268392b76496f752d9e010c6">More...</a><br/></td></tr>
<tr class="separator:af8fafa8e268392b76496f752d9e010c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0960d05e9a2bab88c75505e4286de10a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a0960d05e9a2bab88c75505e4286de10a">qlist_getnext</a> (qlist_t *list, qlist_obj_t *obj, bool newmem)</td></tr>
<tr class="memdesc:a0960d05e9a2bab88c75505e4286de10a"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;getnext(): Get next element in this list.  <a href="#a0960d05e9a2bab88c75505e4286de10a">More...</a><br/></td></tr>
<tr class="separator:a0960d05e9a2bab88c75505e4286de10a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7fd9cac72fbe05f5dabf4dbde43ffd2e"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a7fd9cac72fbe05f5dabf4dbde43ffd2e">qlist_size</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a7fd9cac72fbe05f5dabf4dbde43ffd2e"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;size(): Returns the number of elements in this list.  <a href="#a7fd9cac72fbe05f5dabf4dbde43ffd2e">More...</a><br/></td></tr>
<tr class="separator:a7fd9cac72fbe05f5dabf4dbde43ffd2e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a666371a40b3d4347e0a73add22e90e1a"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a666371a40b3d4347e0a73add22e90e1a">qlist_datasize</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a666371a40b3d4347e0a73add22e90e1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;size(): Returns the sum of total element size.  <a href="#a666371a40b3d4347e0a73add22e90e1a">More...</a><br/></td></tr>
<tr class="separator:a666371a40b3d4347e0a73add22e90e1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a18e9f1aaca165a95810f7889ff27088e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a18e9f1aaca165a95810f7889ff27088e">qlist_reverse</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a18e9f1aaca165a95810f7889ff27088e"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;reverse(): Reverse the order of elements.  <a href="#a18e9f1aaca165a95810f7889ff27088e">More...</a><br/></td></tr>
<tr class="separator:a18e9f1aaca165a95810f7889ff27088e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e982d17fa5c0d2d8a2380b54aad7fbd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a8e982d17fa5c0d2d8a2380b54aad7fbd">qlist_clear</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a8e982d17fa5c0d2d8a2380b54aad7fbd"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;clear(): Removes all of the elements from this list.  <a href="#a8e982d17fa5c0d2d8a2380b54aad7fbd">More...</a><br/></td></tr>
<tr class="separator:a8e982d17fa5c0d2d8a2380b54aad7fbd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acd6f76ee0d811b1c7f9be494bded46f3"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#acd6f76ee0d811b1c7f9be494bded46f3">qlist_toarray</a> (qlist_t *list, size_t *size)</td></tr>
<tr class="memdesc:acd6f76ee0d811b1c7f9be494bded46f3"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;toarray(): Returns the serialized chunk containing all the elements in this list.  <a href="#acd6f76ee0d811b1c7f9be494bded46f3">More...</a><br/></td></tr>
<tr class="separator:acd6f76ee0d811b1c7f9be494bded46f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a27432727387f75f1118dcadb818bc5"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a4a27432727387f75f1118dcadb818bc5">qlist_tostring</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a4a27432727387f75f1118dcadb818bc5"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;tostring(): Returns a string representation of this list, containing string representation of each element.  <a href="#a4a27432727387f75f1118dcadb818bc5">More...</a><br/></td></tr>
<tr class="separator:a4a27432727387f75f1118dcadb818bc5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a49359e2de05870c5a6b8c1e8445c6865"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a49359e2de05870c5a6b8c1e8445c6865">qlist_debug</a> (qlist_t *list, FILE *out)</td></tr>
<tr class="memdesc:a49359e2de05870c5a6b8c1e8445c6865"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;debug(): Prints out stored elements for debugging purpose.  <a href="#a49359e2de05870c5a6b8c1e8445c6865">More...</a><br/></td></tr>
<tr class="separator:a49359e2de05870c5a6b8c1e8445c6865"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab4703d7188e6d1e5ca73827fc1aa29ad"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#ab4703d7188e6d1e5ca73827fc1aa29ad">qlist_lock</a> (qlist_t *list)</td></tr>
<tr class="memdesc:ab4703d7188e6d1e5ca73827fc1aa29ad"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;lock(): Enters critical section.  <a href="#ab4703d7188e6d1e5ca73827fc1aa29ad">More...</a><br/></td></tr>
<tr class="separator:ab4703d7188e6d1e5ca73827fc1aa29ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a09fa7687257b3ef85eceed06d358e883"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a09fa7687257b3ef85eceed06d358e883">qlist_unlock</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a09fa7687257b3ef85eceed06d358e883"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;unlock(): Leaves critical section.  <a href="#a09fa7687257b3ef85eceed06d358e883">More...</a><br/></td></tr>
<tr class="separator:a09fa7687257b3ef85eceed06d358e883"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a44e5775a38a30246388b5999a7ad7596"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qlist_8c.html#a44e5775a38a30246388b5999a7ad7596">qlist_free</a> (qlist_t *list)</td></tr>
<tr class="memdesc:a44e5775a38a30246388b5999a7ad7596"><td class="mdescLeft">&#160;</td><td class="mdescRight">qlist-&gt;free(): Free qlist_t.  <a href="#a44e5775a38a30246388b5999a7ad7596">More...</a><br/></td></tr>
<tr class="separator:a44e5775a38a30246388b5999a7ad7596"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Doubly Linked-list implementation. </p>
<p>qlist container is a doubly Linked-List implementation. qlist provides uniformly named methods to add, get, pop and remove an element at the beginning and end of the list. These operations allow qlist to be used as a stack, queue, or double-ended queue.</p>
<div class="fragment"><div class="line">[Conceptional Data Structure Diagram]</div>
<div class="line"></div>
<div class="line">last~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+</div>
<div class="line">                                                        |</div>
<div class="line">        +-----------+  doubly  +-----------+  doubly  +-|---------+</div>
<div class="line">first~~~|~&gt;   0   &lt;~|~~~~~~~~~~|~&gt;   1   &lt;~|~~~~~~~~~~|~&gt;   N     |</div>
<div class="line">        +-----|-----+  linked  +-----|-----+  linked  +-----|-----+</div>
<div class="line">              |                      |                      |</div>
<div class="line">        +-----v---------------+      |                +-----v-----+</div>
<div class="line">        | DATA A              |      |                | DATA N    |</div>
<div class="line">        +---------------------+      |                +-----------+</div>
<div class="line">               +---------------------v------------------+</div>
<div class="line">               | DATA B                                 |</div>
<div class="line">               +----------------------------------------+</div>
</div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">// create a list.</span></div>
<div class="line">qlist_t *list = <a class="code" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a>(QLIST_THREADSAFE);</div>
<div class="line"></div>
<div class="line"><span class="comment">// insert elements</span></div>
<div class="line">list-&gt;addlast(list, <span class="stringliteral">&quot;e1&quot;</span>, <span class="keyword">sizeof</span>(<span class="stringliteral">&quot;e1&quot;</span>));</div>
<div class="line">list-&gt;addlast(list, <span class="stringliteral">&quot;e2&quot;</span>, <span class="keyword">sizeof</span>(<span class="stringliteral">&quot;e2&quot;</span>));</div>
<div class="line">list-&gt;addlast(list, <span class="stringliteral">&quot;e3&quot;</span>, <span class="keyword">sizeof</span>(<span class="stringliteral">&quot;e3&quot;</span>));</div>
<div class="line"></div>
<div class="line"><span class="comment">// get</span></div>
<div class="line"><span class="keywordtype">char</span> *e1 = (<span class="keywordtype">char</span>*)list-&gt;getfirst(list, NULL, <span class="keyword">true</span>));    <span class="comment">// malloced</span></div>
<div class="line"><span class="keywordtype">char</span> *e3  = (<span class="keywordtype">char</span>*)list-&gt;getat(list, -1, NULL, <span class="keyword">false</span>)); <span class="comment">// no malloc</span></div>
<div class="line">(...omit...)</div>
<div class="line">free(e1);</div>
<div class="line"></div>
<div class="line"><span class="comment">// pop (get and remove)</span></div>
<div class="line"><span class="keywordtype">char</span> *e2 = (<span class="keywordtype">char</span>*)list-&gt;popat(list, 1, NULL)); <span class="comment">// get malloced copy</span></div>
<div class="line">(...omit...)</div>
<div class="line">free(e2);</div>
<div class="line"></div>
<div class="line"><span class="comment">// debug output</span></div>
<div class="line">list-&gt;debug(list, stdout, <span class="keyword">true</span>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// traversal</span></div>
<div class="line">qlist_obj_t obj;</div>
<div class="line">memset((<span class="keywordtype">void</span>*)&amp;obj, 0, <span class="keyword">sizeof</span>(obj)); <span class="comment">// must be cleared before call</span></div>
<div class="line">list-&gt;lock(list);</div>
<div class="line"><span class="keywordflow">while</span> (list-&gt;getnext(list, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line">  printf(<span class="stringliteral">&quot;DATA=%s, SIZE=%zu\n&quot;</span>, (<span class="keywordtype">char</span>*)obj.data, obj.size);</div>
<div class="line">}</div>
<div class="line">list-&gt;unlock(list);</div>
<div class="line"></div>
<div class="line"><span class="comment">// free object</span></div>
<div class="line">list-&gt;free(list);</div>
</div><!-- fragment --> 
<p>Definition in file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a171f1b505417b5a936e198993c9cb372"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlist_t* qlist </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>options</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create new qlist_t linked-list container. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">options</td><td>combination of initialization options.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of malloced qlist_t container, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOMEM : Memory allocation failure.</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">qlist_t *list = <a class="code" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a>(0);</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Available options:<ul>
<li>QLIST_THREADSAFE - make it thread-safe. </li>
</ul>
</dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00124">124</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="ad269a073f8f138a89d91fffccf4878b2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qlist_setsize </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>max</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;setsize(): Limit maximum number of elements allowed in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">max</td><td>maximum number of elements. 0 means no limit.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>previous maximum number.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>The default maximum number of elements is unlimited. </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00190">190</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a362b854c881d11e4ff063bf2415e1202"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_addfirst </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;addfirst(): Inserts a element at the beginning of this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">data</td><td>a pointer which points data memory. </td></tr>
    <tr><td class="paramname">size</td><td>size of the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : List full. Only happens when this list has set to have limited number of elements.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="comment">// create a sample object.</span></div>
<div class="line"><span class="keyword">struct </span>my_obj obj;</div>
<div class="line"></div>
<div class="line"><span class="comment">// create a list and add the sample object.</span></div>
<div class="line">qlist_t *list = <a class="code" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a>();</div>
<div class="line">list-&gt;addfirst(list, &amp;obj, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> my_obj));</div>
</div><!-- fragment --> 
<p>Definition at line <a class="el" href="qlist_8c_source.html#l00221">221</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a5fd1656d6b3534341d7775b201b70f3d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_addlast </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;addlast(): Appends a element to the end of this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">data</td><td>a pointer which points data memory. </td></tr>
    <tr><td class="paramname">size</td><td>size of the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : List full. Only happens when this list has set to have limited number of elements.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00239">239</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a29a98c9eb9a93b096ca15db02010059a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_addat </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;addat(): Inserts a element at the specified position in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">index</td><td>index at which the specified element is to be inserted. </td></tr>
    <tr><td class="paramname">data</td><td>a pointer which points data memory. </td></tr>
    <tr><td class="paramname">size</td><td>size of the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOBUFS : List full. Only happens when this list has set to have limited number of elements.</li>
<li>ERANGE : Index out of range.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">                   first           last      <span class="keyword">new</span></div>
<div class="line">Linked-list        [ A ]&lt;=&gt;[ B ]&lt;=&gt;[ C ]?==?[   ]</div>
<div class="line">(positive index)     0       1       2        3</div>
<div class="line">(negative index)    -3      -2      -1</div>
</div><!-- fragment --><div class="fragment"><div class="line">qlist_t *list = <a class="code" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a>();</div>
<div class="line">list-&gt;addat(list, 0, &amp;obj, <span class="keyword">sizeof</span>(obj));  <span class="comment">// same as addfirst().</span></div>
<div class="line">list-&gt;addat(list, -1, &amp;obj, <span class="keyword">sizeof</span>(obj)); <span class="comment">// same as addlast().</span></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Index starts from 0. </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00276">276</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="ae591e0ee1380e484a7707beed87ada6f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_getfirst </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;getfirst(): Returns the first element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the element.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : List is empty.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><span class="keywordtype">size_t</span> size;</div>
<div class="line"><span class="keywordtype">void</span> *data = list-&gt;getfirst(list, &amp;size, <span class="keyword">true</span>);</div>
<div class="line"><span class="keywordflow">if</span> (data != NULL) {</div>
<div class="line">  (...omit...)</div>
<div class="line">  free(data);</div>
<div class="line">}</div>
</div><!-- fragment --> 
<p>Definition at line <a class="el" href="qlist_8c_source.html#l00389">389</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a8aa5812e608102e152a4e6c906fd848c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_getlast </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;getlast(): Returns the last element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the element.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. ENOENT : List is empty. ENOMEM : Memory allocation failure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00405">405</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="ae5158e057b797633b43190806fc49ce8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_getat </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;getat(): Returns the element at the specified position in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">index</td><td>index at which the specified element is to be inserted </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the element.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td></td></tr>
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ERANGE : Index out of range. -ENOMEM : Memory allocation failure.</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">                   first           last</div>
<div class="line">Linked-list        [ A ]&lt;=&gt;[ B ]&lt;=&gt;[ C ]</div>
<div class="line">(positive index)     0       1       2</div>
<div class="line">(negative index)    -3      -2      -1</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Negative index can be used for addressing a element from the end in this stack. For example, index -1 is same as getlast() and index 0 is same as getfirst(); </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00436">436</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="ab988e96c223ecdf63105f6797e42ecd9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_popfirst </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;popfirst(): Returns and remove the first element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of malloced element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00451">451</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a19d80e0634bda2350372bc15f5b92970"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_poplast </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;getlast(): Returns and remove the last element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of malloced element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00466">466</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a083e4eb3b82834756608e88a15a38164"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_popat </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;popat(): Returns and remove the element at the specified position in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">index</td><td>index at which the specified element is to be inserted </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, element size will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of malloced element, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ERANGE : Index out of range. -ENOMEM : Memory allocation failure.</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">                   first           last</div>
<div class="line">Linked-list        [ A ]&lt;=&gt;[ B ]&lt;=&gt;[ C ]</div>
<div class="line">(positive index)     0       1       2</div>
<div class="line">(negative index)    -3      -2      -1</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Negative index can be used for addressing a element from the end in this stack. For example, index -1 is same as poplast() and index 0 is same as popfirst(); </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00495">495</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a7bbafb0265dbbd962629fbc6beec9a9d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_removefirst </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;removefirst(): Removes the first element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a number of removed objects. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00508">508</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a2148cf9191e31eed686f9c3894ee7fc9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_removelast </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;removelast(): Removes the last element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a number of removed objects. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00521">521</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="af8fafa8e268392b76496f752d9e010c6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_removeat </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;removeat(): Removes the element at the specified position in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">index</td><td>index at which the specified element is to be removed.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a number of removed objects. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ERANGE : Index out of range. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00536">536</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a0960d05e9a2bab88c75505e4286de10a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_getnext </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qlist_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;getnext(): Get next element in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">obj</td><td>found data will be stored in this structure </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the element.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if found otherwise returns false </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : No next element. -ENOMEM : Memory allocation failure.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>obj should be initialized with 0 by using memset() before first call. If newmem flag is true, user should de-allocate obj.name and obj.data resources.</dd></dl>
<div class="fragment"><div class="line">qlist_t *list = <a class="code" href="qlist_8c.html#a171f1b505417b5a936e198993c9cb372">qlist</a>();</div>
<div class="line">(...add data into list...)</div>
<div class="line"></div>
<div class="line">qlist_obj_t obj;</div>
<div class="line">memset((<span class="keywordtype">void</span>*)&amp;obj, 0, <span class="keyword">sizeof</span>(obj)); <span class="comment">// must be cleared before call</span></div>
<div class="line">list-&gt;lock(list);   <span class="comment">// can be omitted in single thread model.</span></div>
<div class="line"><span class="keywordflow">while</span> (list-&gt;getnext(list, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line"> printf(<span class="stringliteral">&quot;DATA=%s, SIZE=%zu\n&quot;</span>, (<span class="keywordtype">char</span>*)obj.data, obj.size);</div>
<div class="line">}</div>
<div class="line">list-&gt;unlock(list); <span class="comment">// release lock.</span></div>
</div><!-- fragment --> 
<p>Definition at line <a class="el" href="qlist_8c_source.html#l00583">583</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a7fd9cac72fbe05f5dabf4dbde43ffd2e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qlist_size </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;size(): Returns the number of elements in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the number of elements in this list. </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00631">631</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a666371a40b3d4347e0a73add22e90e1a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qlist_datasize </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;size(): Returns the sum of total element size. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the sum of total element size. </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00642">642</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a18e9f1aaca165a95810f7889ff27088e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qlist_reverse </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;reverse(): Reverse the order of elements. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00651">651</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a8e982d17fa5c0d2d8a2380b54aad7fbd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qlist_clear </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;clear(): Removes all of the elements from this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00673">673</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="acd6f76ee0d811b1c7f9be494bded46f3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* qlist_toarray </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;toarray(): Returns the serialized chunk containing all the elements in this list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">size</td><td>if size is not NULL, chunk size will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a malloced pointer, otherwise(if there is no data to merge) returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00703">703</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a4a27432727387f75f1118dcadb818bc5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* qlist_tostring </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;tostring(): Returns a string representation of this list, containing string representation of each element. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a malloced pointer, otherwise(if there is no data to merge) returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -ENOENT : List is empty. -ENOMEM : Memory allocation failure.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Return string is always terminated by '\0'. </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00748">748</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a49359e2de05870c5a6b8c1e8445c6865"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qlist_debug </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;debug(): Prints out stored elements for debugging purpose. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
    <tr><td class="paramname">out</td><td>output stream FILE descriptor such like stdout, stderr.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition. -EIO : Invalid output stream. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00789">789</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="ab4703d7188e6d1e5ca73827fc1aa29ad"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qlist_lock </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;lock(): Enters critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>From user side, normally locking operation is only needed when traverse all elements using qlist-&gt;getnext(). </dd></dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00817">817</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a09fa7687257b3ef85eceed06d358e883"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qlist_unlock </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;unlock(): Leaves critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00826">826</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
<a class="anchor" id="a44e5775a38a30246388b5999a7ad7596"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qlist_free </td>
          <td>(</td>
          <td class="paramtype">qlist_t *&#160;</td>
          <td class="paramname"><em>list</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qlist-&gt;free(): Free qlist_t. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">list</td><td>qlist_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="qlist_8c_source.html#l00835">835</a> of file <a class="el" href="qlist_8c_source.html">qlist.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_0b61c55142250c0cc363383afd8075a4.html">containers</a></li><li class="navelem"><a class="el" href="qlist_8c.html">qlist.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
